package com.lottery.im.module.chat.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lottery.im.R;
import com.lottery.im.api.Api;
import com.lottery.im.api.result.entity.ReceivedRedPackets;
import com.lottery.im.util.DateUtils;
import com.lottery.im.util.transformations.CropCircleTransformation;
import java.text.DecimalFormat;
import java.util.List;

public class RedPacketsReceivedAdapter
    extends BaseQuickAdapter<ReceivedRedPackets, BaseViewHolder> {

  public RedPacketsReceivedAdapter(@Nullable List<ReceivedRedPackets> data) {
    super(R.layout.item_redpacketsreceived, data);
  }

  @Override protected void convert(BaseViewHolder helper, ReceivedRedPackets item) {

    ImageView ivPortrait = helper.getView(R.id.iv_portrait);
    Glide.with(mContext)
        .load(Api.BASEADDRESS + item.getUserImg())
        .apply(new RequestOptions()
            .bitmapTransform(new CropCircleTransformation())
            .placeholder(R.drawable.icon_conversation_de)
            .error(R.drawable.icon_conversation_de))
        .into(ivPortrait);
    helper.setText(R.id.tv_name, item.getUserName());
    helper.setText(R.id.tv_time, DateUtils.strAllTime2AllFormat(item.getCreatTime()));
    DecimalFormat df = new DecimalFormat("#0.00");
    helper.setText(R.id.tv_money, df.format(item.getMoney()) + "元");
  }
}
